package il.adscan.scan.impl;

import il.adscan.domain.Advertisement;
import org.jsoup.nodes.Element;

import java.util.concurrent.Callable;

public class AdScraperYad2 implements AdScraper {

    private Element element;
    private final Yad2Scanner yad2Scanner;

    public AdScraperYad2(Element element, Yad2Scanner yad2Scanner) {
        this.element = element;
        this.yad2Scanner = yad2Scanner;
    }

    @Override
    public Advertisement call() throws Exception {
        String linkAttr = element.childNodes().get(39).childNodes().get(3).attr("href");
        String link = Yad2Scanner.BASE_URL + linkAttr;
        Advertisement advertisement = yad2Scanner.getAdvertisementFromLink(link);
//        advertisement.setTimeAdded(element.select(".reddate").html());
        return advertisement;
    }
}
